<#assign formid=auth.getuuid()>
<#assign tableid=auth.getuuid()>
<#assign processnameid=auth.getuuid()>
<#assign processtreeid=auth.getuuid()>
<script type="text/javascript">
function custom_upload_success(file, data, $upload){
	var json = $.parseJSON(data)
    if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
    	$("#${formid}").alertmsg('correct', json[BJUI.keys.message]);
    	$.CurrentNavtab.navtab('reloadForm', true);
    }else{
    	$("#${formid}").alertmsg('error', json[BJUI.keys.message]);
    }
}
var gprocessid = "";
<#if auth.getauth(userid,"/Flow/process_getuser")>
$(function(){
	$("#${tableid}").find("tbody > tr").bind("click",function(){
		var processid = $($(this).find("input")[0]).val();
		var processname = $($(this).find("input")[1]).val();
		if(gprocessid!=processid){
			$('#${tableid}').bjuiajax('doLoad', {url:"${rootpath}/Flow/process_getuser?processid="+processid, target:"#${processtreeid}"});
			$('#${processnameid}').text("【"+processname+"】权限");
			gprocessid = processid;
		}
	});
});
</#if>
</script>
<div class="bjui-pageHeader">
	<form id="pagerForm" data-toggle="ajaxsearch" action="${rootpath}/Flow/process" method="post">
        <input type="hidden" name="pageSize" value="${(page.pageSize)!15}">
        <input type="hidden" name="pageCurrent" value="${(page.pageCurrent)!1}">
        <input type="hidden" name="orderField" value="${(page.orderField)!"name"}">
        <input type="hidden" name="orderDirection" value="${(page.orderDirection)!"asc"}">
        
        <div class="bjui-searchBar">
        	<#if auth.getauth(userid,"/Snaker/processdesign")>
        	<a href="${rootpath}/Snaker/processdesign?processid=new" data-toggle="dialog" data-id="${auth.getuuid()}" 
                        			data-width="980" data-height="780" data-mask="true" data-type="POST" 
                        			data-title="新建流程图" class="btn btn-blue">新建流程图</a>&nbsp;
            </#if>
            <#if auth.getauth(userid,"/Snaker/deploy")>
        	<a
                            data-toggle="upload" 
                            data-button-text="选择流程文件-新建流程图" data-auto="true" 
                            data-preview-img="false" 
                            data-uploader="${rootpath}/Snaker/deploy" 
                            data-file-size-limit="1024000000" 
                            data-file-type-exts="*.snaker" 
                            data-on-upload-success="custom_upload_success"></a>&nbsp;
            </#if>
            <label>流程：</label><input type="text" value="${name!}" name="name" size="10" />&nbsp;
            <label>显示名称：</label><input type="text" value="${display_Name!}" name="display_Name" size="8" />&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true)" data-icon="undo">清空查询</a>&nbsp;
            <div class="pull-right">
				
            </div>
        </div>
    </form>
</div>
<div class="bjui-pageContent tableContent">
	<div class="col-md-8">
    <form action="" id="${formid}" class="pageForm" data-toggle="validate" method="post">
        <table id="${tableid}" class="table table-bordered table-hover table-striped table-top" data-toggle="tabledit" data-layout-h="0">
            <thead>
                <tr>
                    <th data-order-field="id" title="ID" width="200"><input type="text" name="id"   value="" ></th>
                    <th data-order-field="name" title="流程" width="200"><input type="text" name="name"  value="" ></th>
                    <th data-order-field="display_Name" title="显示名称" width="200"><input type="text" name="display_Name"  value="" ></th>
                	<th data-order-field="state" title="状态" width="80"><input type="text" name="state"  value="" ></th>
                	<th data-order-field="version" title="版本" width="80"><input type="text"  name="version" value="" ></th>
                	<th title="操作" width="150">
                	</th>
                </tr>
            </thead>
            <tbody>
                <#if (page.pageData)?exists>
	                <#list page.pageData as item>
	                	<#if item?exists>
	                		<tr data-id="${item.id!}">
				                <td>${item.id!}</td>
				                <td>${item.name!}</td>
				                <td>${item.display_Name!}</td>
				                <td>${item.state?c!}</td>
				                <td>${item.version!}</td>
				                <td data-notread="true">
				                	<#if auth.getauth(userid,"/Snaker/processdesign")>
                        			<a href="${rootpath}/Snaker/processdesign?processid=${item.id}" data-toggle="dialog" data-id="snakerprocessdesign" 
                        			data-width="980" data-height="780" data-mask="true" data-type="POST" 
                        			data-title="设计流程图" class="btn btn-blue">设计流程图</a>
                        			</#if>
                    			</td>
				            </tr>
	                	</#if>
	                </#list>
            	</#if>
            </tbody>
        </table>
 	</form>
 	</div>
 	<div class="col-md-4" style="margin-top: 10px;">
 		<#if auth.getauth(userid,"/Flow/process_getuser")>
 		<fieldset>
            <legend id="${processnameid}">权限</legend>
            	<div id="${processtreeid}" class="bjui-layout" style="height:625px;overflow: auto;">
            		单击表格行显示数据
                </div>
        </fieldset>
        </#if>
 	</div>
    <div class="bjui-pageFooter">
		<div class="pages">
			<span>每页&nbsp;</span>
			<div class="selectPagesize">
				<select data-toggle="selectpicker" data-defval="${page.pageSize!}" data-toggle-change="changepagesize" >
		    		<option value="15">15</option>
		        	<option value="30">30</option>
		        	<option value="50">50</option>
		        	<option value="100">100</option>
		    	</select>
			</div>
			<span>&nbsp;条，共 ${(page.totalRow)!0} 条</span>
		</div>
		<div class="pagination-box" data-toggle="pagination" data-total="${(page.totalRow)!0}" data-page-size="${(page.pageSize)!15}" data-page-current="${(page.pageCurrent)!1}">
		</div>
	</div>
</div>




